package com.shms.service.impl;

import java.util.List;

import com.shms.bean.GroupOfTrends;
import com.shms.bean.IndexParam;
import com.shms.dao.ShTrendsDao;
import com.shms.entity.ShTrends;
import com.shms.service.ShTrendsService;

/**
 * 文件名：ShTrendsServiceImpl.java
 * 编写者：陆遥
 * 创建时间：2013-3-14
 * 简要描述：
 * 动态信息的业务处理类
 */
public class ShTrendsServiceImpl implements ShTrendsService {

	private ShTrendsDao shTrendsDao;
	
	public List<ShTrends> queryTrendsByExample(IndexParam indexParam) {
		return shTrendsDao.queryTrendsByExample(indexParam);
	}
	
	public GroupOfTrends queryTrends(GroupOfTrends groupOfTrends) {
		if (groupOfTrends.getType().equals("forward")) {
			int currentPage = groupOfTrends.getCurrentPage() - 2;
			groupOfTrends.setCurrentPage(currentPage);
		}
		return shTrendsDao.queryTrends(groupOfTrends);
	}
	
	public boolean saveTrends(ShTrends shTrends) {
		boolean rtn = true;
		if (shTrends.getTid() == 0) {
			rtn = shTrendsDao.saveTrends(shTrends);
		} else {
			rtn = shTrendsDao.updateTrends(shTrends);
		}
		return rtn;
	}
	
	public ShTrends queryById(ShTrends shTrends) {
		return shTrendsDao.queryById(shTrends);
	}

	public boolean batchDelete(Integer[] nos){
		return this.shTrendsDao.batchDelete(nos);
	}
	
	public void setShTrendsDao(ShTrendsDao shTrendsDao) {
		this.shTrendsDao = shTrendsDao;
	}
}
